public class test525_1 {
    public static void main(String[] args) {
        //案例一********数组统计：求总和、均值
        int[] arr1 = {33,44,55,66,77};
        //记录总和
        int sum = 0;
        for (int i = 0; i < arr1.length; i++) {
            sum += arr1[i];
        }
        //求均值
        int avg = sum / arr1.length;
        System.out.println("总和为：" + sum + "\n均值为：" + avg);
        //案例二********求数组元素的总乘积
        int[] arr2 = {13,14,520};
        //记录元素的乘积
        int all = 1;
        for (int i = 0; i < arr2.length; i++) {
            all *= arr2[i];
        }
        System.out.println("乘积为：" + all);
        //案例三********求数组元素中偶数的个数
        int[] arr3 = {0,4,6,43,55,22,32,99,43};
        //记录偶数的个数
        int count = 0;
        for (int i = 0; i < arr3.length; i++) {
            if (arr3[i] % 2 == 0) {
                count++;
            }
        }
        System.out.println("偶数的个数为：" + count);
        //案例四********求数组元素的最大值以及它的下标
        int[] arr4 = {29,34,56,123,456,999};
        //用新声明的数一个个的比较数组中的元素，进而找最大数
        int max = arr4[0];
        int n = 0;
        for (int i = 1; i < arr4.length; i++) {
            if (max < arr4[i]) {
                max = arr4[i];
                n = i;
            }
        }
        System.out.println("最大值为：" + max + "\n下标为：" + n);
    }
}
